Correctly check buffer mtime when displaying xref matches
authorSpencer Baugh <sbaugh@janestreet.com>
Tue, 26 Mar 2024 12:44:25 +0000 (08:44 -0400)
committerDmitry Gutov <dmitry@gutov.dev>
Thu, 28 Mar 2024 03:23:23 +0000 (05:23 +0200)
This was just a typo: we were checking the modification time of
current-buffer instead of checking the modification time of the
passed-in buffer.

This caused matches to not be shown if they weren't present in
the current in-Emacs state of the buffer.

This was easily reproduced by writing a string to a file outside
Emacs, then searching for that string with
e.g. project-find-regexp.  The string would seemingly not be
found, although in reality it was found, just not displayed.

* lisp/progmodes/xref.el (xref--find-file-buffer):
Check buf, not current-buffer (bug#70008).

lisp/progmodes/xref.el

index 717b837a2e59676c3e9e8256c5d81dcdb0aed7a8..755c3db04fd9792dbc8e0bd473fa238606dbc4d3 100644 (file)
@@ -2176,7 +2176,7 @@ Such as the current syntax table and the applied syntax properties."
                  (or
                   (buffer-modified-p buf)
                   (unless xref--hits-remote-id
-                    (not (verify-visited-file-modtime (current-buffer))))))
+                    (not (verify-visited-file-modtime buf)))))
         ;; We can't use buffers whose contents diverge from disk (bug#54025).
         (setq buf nil))
       (setq xref--last-file-buffer (cons file buf))))